<script language="javascript" type="text/javascript" src="js/validar_frequencia.js"></script>

<legend>FREQUÊNCIA / CONTEÚDO E PROCEDIMENTOS</legend>

<form name="form" method="post" action="<?php echo $this->basePath('academico/frequencia/salvar'); ?>" onsubmit="return validar();">
    <input type="hidden" name="aula" value="<?php echo ($rowAula) ? $rowAula->id_aula : ''; ?>">
<?php
// prepara dados para salvar
$data = new \DateTime();
if ($rowAula) {
    $data = new \DateTime($rowAula->dt_aula);
}
$dtAula = $data->format('d/m/Y');
?>
<div class="form-group">
    <label class="col-md-2" for="data">Data :</label>
    <span class="col-md-2">
        <input type="text" class="form-control" name="data" value="<?php echo $dtAula; ?>" id="data" required="required">
    </span>
</div>
<div class="form-group">
    <label for="conteudo">Conteúdo e procedimentos :</label><br />
    <textarea name="conteudo" id="conteudo" cols="45" rows="5"><?php echo ($rowAula) ? $rowAula->st_conteudo : ''; ?></textarea>
</div>
<table>
    <tr>
        <th>Aluno</th>
        <th>P</th>
        <th>F</th>
        <th>FJ</th>
        <th>Informações Complementares</th>
    </tr>
    <?php foreach ($rsAlunos as $rAluno) :
        $csFrequencia = '';
        if ($rowAula) {
            $csFrequencia = isset($aFrequencias[$rowAula->id_aula][$rAluno->id_aluno]) ? $aFrequencias[$rowAula->id_aula][$rAluno->id_aluno] : '';
        }
    ?>
    <tr>
        <td><?php echo $rAluno->st_nome; ?></td>
        <td><input type="radio" name="aFrequencias[<?php echo $rAluno->id_aluno; ?>]" value="P" <?php echo ('P' == $csFrequencia) ? 'checked="checked"' : ''; ?>></td>
        <td><input type="radio" name="aFrequencias[<?php echo $rAluno->id_aluno; ?>]" value="F" <?php echo ('F' == $csFrequencia) ? 'checked="checked"' : ''; ?>></td>
        <td><input type="radio" name="aFrequencias[<?php echo $rAluno->id_aluno; ?>]" value="J" <?php echo ('J' == $csFrequencia) ? 'checked="checked"' : ''; ?>></td>
        <td><input type="text"  name="aObservacoes[<?php echo $rAluno->id_aluno; ?>]" value=""></td>
    </tr>
    <?php endforeach; ?>
</table>

    <button class="btn btn-sm btn-success">
        <i class="glyphicon glyphicon-ok-sign"></i>
        CONFIRMAR
    </button>
    <?php if ($rowAula) : ?>
    <a href="<?php echo $this->basePath('academico/frequencia/excluir/aula/' . $rowAula->id_aula); ?>" class="btn btn-sm btn-danger">
        <i class="glyphicon glyphicon-remove"></i>
        Excluir
    </a>
    <?php endif; ?>
</form>
